package com.ruoyi.project.mydo.detail.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.mydo.detail.domain.MydoJobDetail;
import com.ruoyi.project.mydo.detail.service.IMydoJobDetailService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 作业子表Controller
 * 
 * @author ruoyi
 * @date 2023-04-10
 */
@Controller
@RequestMapping("/mydo/detail")
public class MydoJobDetailController extends BaseController
{
    private String prefix = "mydo/detail";

    @Autowired
    private IMydoJobDetailService mydoJobDetailService;

    @GetMapping()
    public String detail()
    {
        return prefix + "/detail";
    }

    /**
     * 查询作业子表列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MydoJobDetail mydoJobDetail)
    {

        List<MydoJobDetail> list = mydoJobDetailService.selectMydoJobDetailList(mydoJobDetail);
        return getDataTable(list);
    }

    /**
     * 导出作业子表列表
     */
    @Log(title = "作业子表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MydoJobDetail mydoJobDetail)
    {
        List<MydoJobDetail> list = mydoJobDetailService.selectMydoJobDetailList(mydoJobDetail);
        ExcelUtil<MydoJobDetail> util = new ExcelUtil<MydoJobDetail>(MydoJobDetail.class);
        return util.exportExcel(list, "作业子表数据");
    }

    /**
     * 新增作业子表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存作业子表
     */
    @Log(title = "作业子表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MydoJobDetail mydoJobDetail)
    {
        return toAjax(mydoJobDetailService.insertMydoJobDetail(mydoJobDetail));
    }

    /**
     * 修改作业子表
     */
    @GetMapping("/edit/{jobDetailId}")
    public String edit(@PathVariable("jobDetailId") String jobDetailId, ModelMap mmap)
    {
        MydoJobDetail mydoJobDetail = mydoJobDetailService.selectMydoJobDetailByJobDetailId(jobDetailId);
        mmap.put("mydoJobDetail", mydoJobDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存作业子表
     */
    @Log(title = "作业子表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MydoJobDetail mydoJobDetail)
    {
        return toAjax(mydoJobDetailService.updateMydoJobDetail(mydoJobDetail));
    }

    /**
     * 删除作业子表
     */
    @Log(title = "作业子表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(mydoJobDetailService.deleteMydoJobDetailByJobDetailIds(ids));
    }


    public static void main(String[] args) {
        System.out.println((-2000)-(-14000));
    }





}
